package com.atm.torch;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;

public class TorchActivity extends Activity {
	
	int previousValue;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
       /* int previousValue = Settings.System.getInt(getContentResolver(), 
                Settings.System.SCREEN_BRIGHTNESS,-1); 
        System.out.println("IB "+previousValue);
        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 255);
        */
        SetBright(1.0f);
        
    }
    
    public void SetBright(float value) 
    {
        Window mywindow = getWindow();

        WindowManager.LayoutParams lp = mywindow.getAttributes();

                lp.screenBrightness = value;

                mywindow.setAttributes(lp);
    }
   /* @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	// TODO Auto-generated method stub
    	menu.add(0, 0, 0, "Settings");
    	return true;
    }*/
    
  /*  @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	if(item.getItemId() == 0){
    		showBar();
    	}
    	return true;
    }*/
   /* ProgressDialog progressDialog;
    private void showBar() {
    	//Dialog dialog = new Dialog(this);
		//dialog.setTitle("Adjust Brightness");
		if(progressDialog == null){
			progressDialog = new ProgressDialog(this);
			progressDialog.setMax(255);
			progressDialog.setCancelable(true);
		}
		
		progressDialog.show();
	}*/

	/*@Override
    protected void onStop() {
    	// TODO Auto-generated method stub
    	super.onStop();
    	Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, previousValue);
    }*/
}